import 'package:demo/event/event_message.dart';
import 'package:demo/views/group/group_index_view.dart';
import 'package:flutter/material.dart';
import 'package:demo/config/app_fonts.dart';
import 'package:demo/views/base/base_controller.dart';
import 'package:demo/views/friend/friend_index_view.dart';
import 'package:demo/views/mine/mine_index_view.dart';
import 'package:demo/views/msg/msg_index_view.dart';
import 'package:demo/json/json_friend.dart';
import 'package:demo/json/json_group.dart';

class MainController extends BaseController {
  // 当前页面
  int currentIndex = 0;

  // 索引
  final List<BottomNavigationBarItem> items = [
    const BottomNavigationBarItem(
      label: '消息',
      icon: SizedBox(
        width: 50,
        child: Icon(
          AppFonts.e884,
          size: 30,
        ),
      ),
    ),
    const BottomNavigationBarItem(
      label: '好友',
      icon: SizedBox(
        width: 50,
        child: Icon(
          AppFonts.e622,
          size: 30,
        ),
      ),
    ),
    const BottomNavigationBarItem(
      label: '群聊',
      icon: SizedBox(
        width: 50,
        child: Icon(
          AppFonts.e71e,
          size: 30,
        ),
      ),
    ),
    const BottomNavigationBarItem(
      label: '我的',
      icon: SizedBox(
        width: 50,
        child: Icon(
          AppFonts.e70f,
          size: 30,
        ),
      ),
    ),
  ];

  // 初始化

  // 页面列表
  static List<Widget> children() {
    return [
      const MsgIndexView(),
      const FriendIndexView(),
      const GroupIndexView(),
      const MineIndexView(),
    ];
  }

  @override
  Future<void> onInit() async {
    super.onInit();
    // 好友列表
    JsonFriend.getFriendList();
    // 群聊列表
    JsonGroup.getGroupList();
    // 监听消息
    subscription = EventMessage().addListen();
  }
}
